"use strict"
var fs = require('fs')
var path = require('path')
var rf = require('fs')

module.exports = function(dir) {
  var datas = []

  if (!fs.existsSync(dir)) {
    return null
  }
  let files = fs.readdirSync(dir)
  files.forEach(function(filename) {
    let dataPath = path.join(dir, `/${filename}`)
    let content = rf.readFileSync(dataPath,"utf-8")
    let contents = JSON.parse(content)
    console.log(contents.flow[0].type)
    let modules = []
    /*for(var i = 0; i < contents.topics.length; i ++) {
      datas.push({
        type: contents.id + '/' + contents.topics[i].id,
        payload: contents.topics[i].payload
      })
    }*/
  })
  return datas
}